package com.chzn;

import com.chzn.component.UserService;
import com.chzn.config.AppConfig;
import com.chzn.entity.User;
import com.chzn.factoryBean.MySmartFactoryBean;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor;
import org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver;
import org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.CommonAnnotationBeanPostProcessor;
import org.springframework.context.annotation.ConfigurationClassPostProcessor;
import org.springframework.context.annotation.ContextAnnotationAutowireCandidateResolver;

/**
 * @Description
 * @Author houchenkai
 * @Created Date: 2020/10/22 18:42
 * @ClassName
 */
public class Test {

	/*public static void main(String[] args) {
		ClassPathXmlApplicationContext xmlApplicationContext = new ClassPathXmlApplicationContext("Spring.xml");
		UserService userService = (UserService) xmlApplicationContext.getBean("userService");
		System.out.println(userService);
	}*/

	/**
	 * TODO
	 * @see DefaultListableBeanFactory#resolveDependency(org.springframework.beans.factory.config.DependencyDescriptor, java.lang.String, java.util.Set, org.springframework.beans.TypeConverter)
	 * @see AbstractAutowireCapableBeanFactory#unsatisfiedNonSimpleProperties(org.springframework.beans.factory.support.AbstractBeanDefinition, org.springframework.beans.BeanWrapper)
	 * @see QualifierAnnotationAutowireCandidateResolver
	 * @see ContextAnnotationAutowireCandidateResolver
	 * @see ConfigurationClassPostProcessor
	 * @see AutowiredAnnotationBeanPostProcessor
	 * @see CommonAnnotationBeanPostProcessor
	 * @see ProxyFactory
	 */
	public static void main(String[] args) {
		AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(AppConfig.class);

		System.out.println("==============ac.getBean输出=========================");
		User user = (User) ac.getBean("mySmartFactoryBean");
		System.out.println("mySmartFactoryBean----"+user);
		MySmartFactoryBean smartFactoryBean = (MySmartFactoryBean) ac.getBean("&mySmartFactoryBean");
		System.out.println("&mySmartFactoryBean-----"+smartFactoryBean);
		UserService userService = (UserService) ac.getBean("userService");
		System.out.println("userService------"+userService);
	}
}
